home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 008a / feb93cad.zip / AA_INT.LSP next >
Lisp/Scheme  |  1993-02-12  |  2KB  |  58 lines

  1. ; AA_INT.LSP
  2. ; Purpose: Loaded by XINT.LSP to find intersection of
  3. ; an arc/circle with an
  4. ; arc/circle.  Variables are defined in XINT.LSP
  5. ; Version: 1.1
  6. ; Author: Glenn S. Lyford  5/20/90
  7. ; Revised: George E. Zinsmeister  10/20/90 
  8. ;===============================================
  9. ;
  10. (setq
  11.   C1 (cdr (assoc 10 EL1))   ;center of first arc/circle
  12.   C2 (cdr (assoc 10 EL2))   ;center of second arc/circle
  13.   R1 (cdr (assoc 40 EL1))   ;radius of first arc/circle
  14.   R2 (cdr (assoc 40 EL2))   ;radius of second arc/circle
  15.   DC (distance C1 C2)       ;distance between centers
  16.   DR (+ R1 R2)              ;sum of the radii
  17.   A1 (angle C1 C2)          ;angle of line between centers
  18. )
  19.  
  20. (if (< R1 R2)   ;swap so signs will be correct for finding A2
  21.   (setq R R2 R2 R1 R1 R C1 C2 A1 (+ pi A1)))
  22. (cond
  23.   ((< DC DR)
  24.     (if (and (>= (+ DC R1) R2) (>= (+ DC R2) R1)) 
  25.                                ;calculate if one is
  26.       (progn                   ;not completely inside
  27.         (setq                  ;the other
  28.           S (/ (+ R1 R2 DC) 2) ;half the perimeter
  29.           D (- (* R2 R2) (* R1 R1) (* DC DC))
  30.                                ;difference of squares
  31.           A2 (atan (/ (sqrt (* S (- S R1) (- S R2) 
  32.                    (- S DC))) D -0.25))
  33.                                ;angle of triangle at C1
  34.           P1 (polar C1 (- A1 A2) R1) ;first intersection
  35.           P2 (polar C1 (+ A1 A2) R1) ;second intersection
  36.         )
  37.         (if (<= (distance P1 PS1) (distance P2 PS1)) 
  38.                                ; set PNEAR and PFAR
  39.           (setq PNEAR P1 PFAR P2)
  40.           (setq PFAR P1 PNEAR P2)
  41.         )
  42.         (if (= NF 0) (setq P PNEAR) (setq P PFAR)) 
  43.                                ; choose PNEAR or PFAR
  44.       ) ;end progn
  45.       (setq P nil)       ;one is inside other so return nil
  46.     ) ;end if
  47.   )
  48.   ((equal DC DR (* 0.0001 (getvar "dimscale"))) 
  49.                          ;tangent point
  50.     (setq P (polar C1 A1 R1))
  51.   )
  52.   ; note that "fuzz" to determine tangency is related 
  53.   ; to "dimscale" - this criterion can be changed 
  54.   ; according to specific application
  55.   (setq P nil)           ;too far apart
  56. ) ; end aa_int.lsp
  57.  
  58.